package com.example.demo0

import kotlin.properties.Delegates

interface StockUpdateListener{
    fun onRise(price: Int)
    fun onFall(price: Int)
}


class StockDisplay2:StockUpdateListener{
    override fun onRise(price: Int) {
        TODO("Not yet implemented")
    }

    override fun onFall(price: Int) {
        TODO("Not yet implemented")
    }

}

class StockUpdate2{
    var listeners = mutableSetOf<StockUpdateListener>()

    var price:Int by Delegates.observable(0) {
        _,old,new ->
        listeners.forEach{
            if(new > old)
                it.onRise(price)
            else
                it.onFall(price)
        }
    }

}



